home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2587 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  67 lines

  1. Newsgroups: comp.os.ms-windows.programmer.networks,comp.os.ms-windows.programmer.misc,comp.lang.c,comp.lang.basic.visual.database
  2. Path: in1.uu.net!bcstec!ccmail
  3. From: wasmr600@ccmail.ca.boeing.com (Michael Washington)
  4. Subject: Re: NetBIOS Path Strings and Drive Letter Assignments
  5. X-Nntp-Posting-Host: e593668.evt.boeing.com
  6. Message-ID: <DLLCyB.3MC@bcstec.ca.boeing.com>
  7. Sender: nntp@bcstec.ca.boeing.com (NNTP News Access)
  8. Reply-To: wasmr600@ccmail.ca.boeing.com (Michael Washington)
  9. Organization: The Boeing Company
  10. References: <4dp4l2$bcf@noc.tor.hookup.net>
  11. Date: Mon, 22 Jan 1996 08:26:16 GMT
  12.  
  13. > NetBIOS Path Strings and Drive Letter Assignments
  14. > patrick@xiris.com (Patrick Whittle)
  15. > Fri, 19 Jan 1996 23:06:52 GMT
  16. > Xiris Incorporated
  17. > Newsgroups:
  18. comp.os.ms-windows.programmer.networks,comp.os.ms-windows.programmer.mis
  19. c,comp.lang.c,comp.lang.basic.visual.database
  20. > Hi:
  21. > I am developing an application that accesses a share on our server 
  22. > using a NetBIOS path string (i.e. \\SHARE\NAME\<path>\file.ext). 
  23. > I want to use this path string because the share name will not change,
  24. > whereas the drive letter assignment a given user uses could at any 
  25. > time change. However, there is still a situation where I could make 
  26. > use of an API call that returns a drive letter being used.
  27. > Do you know of an API call that returns network drive letter 
  28. > assignments?  Is there a way to find out what drive is connected to 
  29. > \\SHARE\NAME for example, using the API interface??
  30. > Please respond to patrick@xiris.com
  31. > Thanks ......... PW
  32. > ///////////////////////////////////////////
  33. > Patrick Whittle        Tel: (905) 681-8107
  34. >   Xiris Inc.           FAX: (905) 681-9844
  35. > E-mail:                patrick@xiris.com
  36. > Web Page:              http://www.hookup.net/~xiris/
  37.  
  38. If your network supports UNC you don't need to worry about finding the 
  39. next available drive letter. If it does not try using the following 
  40. function from the Microsoft knowledge base it uses the Win API 
  41. GETDRIVETYPE.
  42.  
  43. Declare Function GetDriveType Lib "kernel" (ByVal nDrive As Integer) As 
  44. Integer
  45.  
  46. Function Freedrv()
  47.  Dim DriveNum As Integer, FirstFreeDrive As String
  48.  Dim FirstDrive As Integer
  49.  DriveNum = -1
  50.  Do 
  51.    DriveNum = DriveNum +1  'start at drive zero
  52.    FirstDrive% = GetDriveType(DriveNum)
  53.    'GetDriveType returns zero if it cannot determine drive
  54.    'type or returns 1 if the specified drive does not exists
  55.  Loop Until FirstDrive% = 0
  56.  'DriveNum of 0 means Drive A, 1=B, 2=C, 3=D , and so on
  57.  FirstFreeDrive = Chr$(DriveNum+65) & ":"
  58.  FreeDrv = FristFreeDrive
  59. End Function
  60.  
  61.  
  62.  
  63.